package com.decoration.basic.service.impl;

import java.util.List;

import javax.annotation.Resource;

import com.decoration.basic.mapper.DecPictureMapper;
import org.springframework.stereotype.Service;

import com.decoration.basic.entity.DecCaseInfBase;
import com.decoration.basic.mapper.DecCaseMapper;
import com.decoration.basic.findCondition.DecCaseFindCondition;
import com.decoration.basic.entity.DecCarouselBase;
import com.decoration.basic.po.DecHomePageList;
import com.decoration.basic.po.DecCaseInfVo;
import com.decoration.basic.service.DecCaseService;

@Service
public class DecCaseServiceImpl implements DecCaseService {

	@Resource
	private DecCaseMapper decMapper;

	//public List<DecCaseInfVo> findAllInfo() {
	@Resource
	private DecPictureMapper picMapper;

	// 获取案例列表
	@Override
	public DecHomePageList findAll() {
		List<DecCarouselBase> carousellist = picMapper.findCaRousel();
		List<DecCaseInfBase> caselist = decMapper.findAllRousel();

		DecHomePageList po = new DecHomePageList();
		po.setCarousellist(carousellist);
		po.setCaselist(caselist);
		return po;
	}

	public List<DecCarouselBase> findAllInfo() {

        //按对应案例id信息填入相关图片信息
       /* List<DecCaseInfPo> caseInfPos = new ArrayList<DecCaseInfPo>();
        for (DecorationCaseInf caseInf :deccaseinf){
            DecCaseInfPo decpo = new DecCaseInfPo();
            decpo.setId(caseInf.getId());
            decpo.setTitle(caseInf.getTitle());
            decpo.setRemark(caseInf.getRemark());

            //获取案例相关图片信息
            List<DecorationPicture> stamplist = new ArrayList<DecorationPicture>();
            for (DecorationPicture picture : piclist){
                if (picture.getCaseId().equals(caseInf.getId())){
                    stamplist.add(picture);
                }
            }


			// 获取案例相关图片信息
			List<DecorationPicture> stamplist = new ArrayList<DecorationPicture>();
			for (DecorationPicture picture : piclist) {
				if (picture.getCaseId().equals(caseInf.getCaseId())) {
					stamplist.add(picture);
				}
			}

			// 将图片信息写入到案例信息中
			decpo.setDecPictures(stamplist);
			caseInfPos.add(decpo);
		}
		return caseInfPos;*/
       return null;
	}

	// 删除案例信息
	@Override
	public int delete(Integer id) {
		return decMapper.delete(id);
	}

	// 更新案例信息
	@Override
	public int update(DecCaseInfBase decCaseInf) {
		// 更新案例信息
		return decMapper.update(decCaseInf);

	}

	@Override
	public int add(DecCaseInfBase decCaseInfo) {
		return decMapper.add(decCaseInfo);
	}

	@Override
	public DecCaseInfVo findById(Integer id) {
		// 通过案例id获取相关案例信息
		return decMapper.findById(id);
	}

	@Override
	public List<DecCaseInfBase> getCaseList(DecCaseFindCondition findCondition) {
		return decMapper.getCaseList(findCondition);
	}

	@Override
	public int getCaseListSize(DecCaseFindCondition findCondition) {
		return decMapper.getCaseListSize(findCondition);
	}

}
